home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / C++ / Applications / Nuntius 1.2 / src / Nuntius / UHashTable.h < prev    next >
Encoding:
Text File  |  1994-02-20  |  1.1 KB  |  48 lines  |  [TEXT/MPS ]

  1. // Copyright © 1992 Peter Speck, speck@dat.ruc.dk. All rights reserved.
  2. // UHashTable.h
  3.  
  4. #define __UHASHTABLE__
  5.  
  6. #ifndef __STDIO__
  7. #include <stdio.h>
  8. #endif
  9.  
  10. const short kHashBitShift = 5;
  11. const short kHashTableEntries = 1 << (2 * kHashBitShift);
  12. const short kHashTableSize = kHashTableEntries * sizeof(ArrayIndex);
  13.  
  14. class THashTable : public TObject
  15. {
  16.     public:
  17.         short HashMessageID(char *p, long &len); // p must CPoint on '<' when called
  18.         // does no mem-move
  19.         
  20.         void  SetValue(short index, ArrayIndex value);
  21.         short GetValue(short index);
  22.         void  FillHashTable(ArrayIndex value);
  23.  
  24.         void DoRead(TStream *aStream);
  25.         void DoWrite(TStream *aStream);
  26.         void DoNeedDiskSpace(long &dataForkBytes);
  27.         
  28.         void DebugDump(FILE *file);
  29.         Boolean SanityCheck();
  30.         
  31.         THashTable();
  32.         pascal void Initialize();
  33.         void IHashTable();
  34.         pascal void Free();
  35.     private:
  36.         ArrayIndex fHashTable[kHashTableEntries];
  37. };
  38.  
  39. inline void THashTable::SetValue(short index, ArrayIndex value)
  40.     fHashTable[index] = value;
  41. }
  42.  
  43. inline short THashTable::GetValue(short index)
  44. {
  45.     return fHashTable[index];
  46. }
  47.